<template>
    <div class="login-wrap">
    <div class="login-form">
        <div class="form-title">有序用电国网端</div>
        <el-form
        :model="formData"
        :rules="rules"
        class="form-content"
        label-width="0px"
        ref="form"
        >
        <el-form-item prop="username">
            <el-input placeholder="账号" v-model="formData.username">
            <span slot="prepend"><i class="el-icon-user"></i></span>
            </el-input>
        </el-form-item>

        <el-form-item prop="password">
            <el-input
            @keyup.enter.native="submit()"
            placeholder="密码"
            type="password"
            v-model="formData.password"
            >
            <span slot="prepend"><i class="el-icon-edit"></i></span>
            </el-input>
        </el-form-item>

        <el-form-item prop="userType">
            <el-radio-group v-model="formData.userType">
            <!-- <el-radio label="1">学生</el-radio>
            <el-radio label="2">教师</el-radio> -->
            <el-radio label="3">管理员</el-radio>
            </el-radio-group>
        </el-form-item>

        <div class="login-btn" v-loading="this.$store.state.loading">
            <el-button @click="submit()" type="primary">登录</el-button>
        </div>
        </el-form>
    </div>
    </div>
</template>

<script>
export default {
    data: function() {
    return {
      formData: {
        username: "",
        password: "",
        userType: "3"
      },
      rules: {
        username: [
          { required: true, message: "请输入账号", trigger: "blur" }
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }],
        userType: [
          { required: true, message: "请选择用户类型", trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    submit() {
    //   this.$refs.form.validate(valid => {
    //     if (valid) {
    //       login(
    //         this.formData.username,
    //         this.formData.password,
    //         this.formData.userType
    //       ).then(res => {
    //         this.$message.success("登录成功: " + res.username);
    //         this.$store.commit("login", res);
    //         this.$router.push({ name: "container" });
    //       });
    //     }
    //   });
    this.$router.push({ name: "admin-home" });
    }
  }
};
</script>

<style scoped>
    .login-wrap {
        position: absolute;
        width: 100%;
        height: 100%;
        background-image: url("");
        background-size: 100% 100%;
      }
      
      .form-title {
        width: 100%;
        line-height: 50px;
        text-align: center;
        font-size: 20px;
        color: #fff;
        border-bottom: 1px solid #ddd;
      }
      
      .login-form {
        position: relative;
        left: 50%;
        top: 50%;
        width: 350px;
        margin: -190px 0 0 -175px;
        border-radius: 5px;
        background: rgba(0, 0, 0, 0.6);
        overflow: hidden;
      }
      
      .form-content {
        padding: 30px 30px;
      }
      
      .login-btn {
        text-align: center;
      }
      
      .login-btn button {
        width: 100%;
        height: 36px;
      }
      
      .el-radio {
        color: #fff;
      }
</style>